package 设计模式;

/**
 * 单例模式：安全的懒汉模式
 */
public class SingletonPattern {
    private SingletonPattern(){}
    private static SingletonPattern instance=null;
    public static SingletonPattern getInstance(){
        if(instance==null) {
            synchronized (SingletonPattern.class) {
                if (instance == null) {
                    instance = new SingletonPattern();
                }
            }
        }
        return instance;
    }
}
